<?php
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/** 
 * Description of ActualizarDatos
 *
 * @author ETorres
 * @export Modules
 * @export-metadata RequiredRoles:ROLE_PROFESSOR
 */
class ActualizarDatos extends Module {

    /**
     *
     * @var Docentes
     */

    public function index() {
        $docente = $this->model->teachers->GetById($this->currentUser->getName());

        $this->assign("docente", $docente);
        $this->assign("action", $this->route->action("Update"));
        $this->display("index");
    }

    public function Update() {
        if ($this->request->submitted()) {
            /* @var $Docentes*/
            Loader::using("models::entities::Docentes");
            $myDocente = new Docentes();
            $myDocente = $this->model->teachers->GetById($this->currentUser->getName());
            
            $this->request->bind($myDocente);
 
            
            $this->model->teachers->Update($myDocente);
            $this->addMessage(new Message("Sus datos personales han sido actualizados correctamente !!", "", Message::SUCCESS));
            $this->assign("action", $this->route->moduleAction("Guardar"));
            $this->display();
        } else {
            $this->index();
        }
    }
    
    
}

?>
